package edu.hgnu.enums;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

/**
 * @author admin
 */

public enum LogType {

    INFO("普通提示信息","info",1),
    DEBUG("普通调试信息","debug",2),
    WARNING("一般警告信息","warning",3),
    ERROR("运行错误信息","error",4);

    //成员变量
    private String text;
    private String value;
    private int index;

    //构造方法
    private LogType(String text,String value,Integer index){
        this.text = text;
        this.value = value;
        this.index = index;
    }

    // 普通方法
    public static String getTextByIndex(int index) {
        for (LogType lt : LogType.values()) {
            if (lt.getIndex() == index) {
                return lt.text;
            }
        }
        throw new IllegalArgumentException("index值非法，没有符合数值状态的枚举对象");
    }

    public static String getValueByIndex(int index) {
        for (LogType lt : LogType.values()) {
            if (lt.getIndex() == index) {
                return lt.value;
            }
        }
        throw new IllegalArgumentException("index值非法，没有符合数值状态的枚举对象");
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}